import Vue  from 'vue'
import Router from 'vue-router'
// 引入一级组件

import DashBoard from './../views/dashboard/DashBoard'
const Home = ()=> import('./../views/home/Home.vue')
const Category = ()=> import('./../views/category/Category.vue')
// 用户中心
const Mine = ()=> import('./../views/mine/Mine.vue')
const UserCenter = ()=>import('./../views/mine/children/UserCenter.vue')
const Cart = ()=> import('./../views/cart/Cart.vue')

const Order = ()=> import('./../views/order/Order.vue')
const MyAddress = ()=> import('./../views/order/children/MyAddress.vue')
const AddAddress = ()=> import('./../views/order/children/children/AddAddress.vue')
const EditAddress = ()=> import('./../views/order/children/children/EditAddress.vue')
// 引入登录
const Login = ()=> import('./../views/login/Login.vue')


Vue.use(Router);

export default new Router({
    routes:[
        {path:'/',redirect:'/dashboard'},
        {
            path:'/dashboard',
            name:'dashboard',
            component:DashBoard,
            children:[
                {path:'/dashboard',redirect:'/dashboard/home'},
                {path:'home',name:'home',component:Home,meta:{keepAlive:true}},
                {path:'category',name:'category',component:Category,meta:{keepAlive:false}},
                {path:'mine',
                name:'mine',
                component:Mine,
                children:[
                    {path:'userCenter',name:'userCenter',component:UserCenter}
                ]
            },
                {path:'cart',name:'cart',component:Cart},
            ]
        },
        {
            path:'/confirmOrder',
            name:'confirmOrder',
            component:Order,
            children:[
                {
                    path:'myAddress',
                    name:'myAddress',
                    component:MyAddress,
                    children:[
                        {path:'addAddress',name:'AddAddress',component:AddAddress},
                        {path:'editAddress',name:'EditAddress',component:EditAddress},

                    ]
                }
            ]


        },
        {path:'/login',name:'loing',component:Login}
    ]
})
